﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="/jquery-3.3.1.min.js" crossorigin="anonymous"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script type="text/javascript">
        $.ajax({
            url: "/api/Identity/CheckSignature",//后台给你提供的接口
            type: "Get",
            async: false,
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                debugger;
                var datad = JSON.parse(data); //转译为Json字符串
                wx.config({
                    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来
                    appId: datad.appid, // 必填，公众号的唯一标识
                    timestamp: datad.timestamp, // 必填，生成签名的时间戳
                    nonceStr: datad.nonceStr, // 必填，生成签名的随机串
                    signature: datad.signature,// 必填，签名，见附录1
                    jsApiList: [
                        "openLocation"
                    ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
                });
                wx.error(function (res) {
                    alert(res);
                });
            },
            error: function (error) {
                alert(error);
            }
        });
    </script>
</head>
<body>
    <form method="post" action="/api/identity/OAuth2">
        <button type="submit" name="provider" value="WeChat">使用微信登陆</button>
    </form>
</body>
</html>